﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace zoombies__
{
    class SlowZombie : Zombies
    {
        List<SlowZombie> slowList = new List<SlowZombie>();
        public SlowZombie(Texture2D texture, Vector2 position, bool Moved, int hp, int dmg, float speed, List<SlowZombie> _slowList)
            :base(texture, position, hp, dmg, speed)
        {
            Moved = false;
            slowList = _slowList;
        }
        public override void Update(GameTime gameTime, Vector2 followPos)
        {
            Vector2 direction = Vector2.Normalize(followPos - this.Position);
            this.position += direction * 1;

            foreach (SlowZombie t in slowList)
            {
                if (t != this && Moved == false)
                {
                    Rectangle otherZombie = t.GetRectangle();
                    Rectangle myZombie = this.GetRectangle();
                    if (myZombie.Intersects(otherZombie) == true)
                    {
                        Point mP = myZombie.Center;
                        Point oP = otherZombie.Center;
                        Vector2 directionBack = new Vector2(oP.X - mP.X, oP.Y - mP.Y);
                        float dist = 2;
                        directionBack.Normalize();

                        if (directionBack.X > 0 && direction.X > 0 && directionBack.Y > 0 && direction.Y > 0 ||
                            directionBack.X > 0 && direction.X > 0 && directionBack.Y < 0 && direction.Y < 0 ||
                            directionBack.X < 0 && direction.X < 0 && directionBack.Y > 0 && direction.Y > 0 ||
                            directionBack.X < 0 && direction.X < 0 && directionBack.Y < 0 && direction.Y < 0)
                        {

                        }
                        else
                        {
                            t.position += directionBack * dist;
                            Moved = true;
                        }



                    }
                }

            }
            base.Update(gameTime, followPos);
        }
    }
}
